package com.fs.chatx.module.task;

import com.fs.chatx.module.chat.config.PromptConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

@Component
public class MyTaskSchdule
{
    @Autowired
    private PromptConfig promptConfig;

    @Scheduled(fixedDelay = 5000)
    public void reloadPrompts() throws IOException
    {
        String extractionPrompt = new String(Files.readAllBytes(Paths.get("prompts/ocr_extraction_prompt.yaml")));
        promptConfig.setExtractionPrompt(extractionPrompt);
    }

}
